package com.qingzhu.dao.impl;

import com.qingzhu.dao.CitiesDao;
import com.qingzhu.pojo.Cities;
import com.qingzhu.util.CreateSqlSessionFactory;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CitiesDaoImpl implements CitiesDao {

    @Override
    public List<Cities> findByProvincesId(String provincesId) {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)) {
            CitiesDao citiesDao = sqlSession.getMapper(CitiesDao.class);
            return citiesDao.findByProvincesId(provincesId);
        }
    }

    @Override
    public Cities findCitiesById(String cityId) {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)) {
            CitiesDao citiesDao = sqlSession.getMapper(CitiesDao.class);
            return citiesDao.findCitiesById(cityId);
        }
    }
}
